package com.codi.bus.core.dao.impl;

import com.codi.base.dao.BaseDAOImpl;
import com.codi.base.dao.PageImpl;
import com.codi.base.dao.plugin.page.PageView;
import com.codi.bus.core.dao.FundWarehouseTransferDao;
import com.codi.bus.core.domain.FundWarehouseTransfer;
import org.springframework.data.domain.Page;
//import org.springframework.data.assets.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository("fundWarehouseTransferDao")
public class FundWarehouseTransferDaoImpl extends BaseDAOImpl<FundWarehouseTransfer> implements FundWarehouseTransferDao {
    @Override
    public Page<FundWarehouseTransfer> queryByPage(Pageable pageable) {
        PageView pageView = getPageView(pageable.getPageNumber(), pageable.getPageSize());
        Map<String, Object> map = new HashMap<>();
        map.put("pageView", pageView);

        List<FundWarehouseTransfer> fundWarehouseTransfers = getSqlSession().selectList(generateStatement("queryByPage"), map);

        return new PageImpl<>(fundWarehouseTransfers, pageable, pageView.getRowCount());
    }

    @Override
    public int addFundWarehouseTransfer(FundWarehouseTransfer transfer) {
        return this.insert(generateStatement("insertSelective"), transfer);
    }

    @Override
    public FundWarehouseTransfer selectOne(Long warehouseId) {
        return this.getObject(generateStatement("selectByPrimaryKey"), warehouseId);
    }

    @Override
    public int deleteByKey(Long warehouseId) {
        return this.delete(generateStatement("deleteByPrimaryKey"), warehouseId);
    }

    @Override
    public int updateOne(FundWarehouseTransfer transfer) {
        return this.update(generateStatement("updateByPrimaryKeySelective"), transfer);
    }

    @Override
    public List<FundWarehouseTransfer> queryByCombinationCode(String combinationCode) {
        return this.findList(generateStatement("queryByCombinationCode"), combinationCode);
    }

    @Override
    public FundWarehouseTransfer queryOneByCombinationCode(String combinationCode) {
        return this.getObject(generateStatement("queryOneByCombinationCode"), combinationCode);
    }

    @Override
    public List<FundWarehouseTransfer> queryByTime(String portfolioCode) {
        return this.findList(generateStatement("queryByTime"), portfolioCode);
    }

    @Override
    public List<FundWarehouseTransfer> getPortfolioTransferSms() {
        return this.findList(generateStatement("getPortfolioTransferSms"));
    }
}
